package com.yanfan.ba.service.impl;

import java.util.Arrays;
import java.util.List;
import com.yanfan.common.utils.StringUtils;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.yanfan.ba.mapper.IbmsBaDataMapper;
import com.yanfan.ba.domain.IbmsBaData;
import com.yanfan.ba.service.IIbmsBaDataService;

/**
 * BA设备数据Service业务层处理
 *
 * @author genluo
 * @date 2024-09-22
 */
@Service
public class IbmsBaDataServiceImpl extends ServiceImpl<IbmsBaDataMapper, IbmsBaData> implements IIbmsBaDataService {
    @Autowired
    private IbmsBaDataMapper ibmsBaDataMapper;


    /**
     * 查询BA设备数据列表
     *
     * @param ibmsBaData BA设备数据
     * @return BA设备数据
     */
    @Override
    public List<IbmsBaData> queryPageList(IbmsBaData ibmsBaData) {
        LambdaQueryWrapper<IbmsBaData> lqw = buildQueryWrapper(ibmsBaData);
        return ibmsBaDataMapper.selectList(lqw);
        //连表查询可用该方法，在此方法SQL语句上进行扩展
        //return ibmsBaDataMapper.queryPageList(ibmsBaData);
    }

    /**
    * 分页查询条件
    * @return
    */
    private LambdaQueryWrapper<IbmsBaData> buildQueryWrapper(IbmsBaData bo) {
        LambdaQueryWrapper<IbmsBaData> lqw = Wrappers.lambdaQuery();
        lqw.eq(bo.getInstanceNumber() != null, IbmsBaData::getInstanceNumber, bo.getInstanceNumber());
        lqw.like(StringUtils.isNotBlank(bo.getName()), IbmsBaData::getName, bo.getName());
        lqw.eq(StringUtils.isNotBlank(bo.getPresentValue()), IbmsBaData::getPresentValue, bo.getPresentValue());
        lqw.eq(StringUtils.isNotBlank(bo.getDescription()), IbmsBaData::getDescription, bo.getDescription());
        lqw.eq(StringUtils.isNotBlank(bo.getObjectType()), IbmsBaData::getObjectType, bo.getObjectType());
        lqw.eq(bo.getCreatedAt() != null, IbmsBaData::getCreatedAt, bo.getCreatedAt());
        lqw.eq(bo.getUpdatedAt() != null, IbmsBaData::getUpdatedAt, bo.getUpdatedAt());
        lqw.eq(StringUtils.isNotBlank(bo.getUnits()), IbmsBaData::getUnits, bo.getUnits());
        lqw.eq(StringUtils.isNotBlank(bo.getRunningType()), IbmsBaData::getRunningType, bo.getRunningType());
        lqw.eq(StringUtils.isNotBlank(bo.getTroubleSignal()), IbmsBaData::getTroubleSignal, bo.getTroubleSignal());
        return lqw;
    }



}
